package 第六章课后作业;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Random;

public class 第三题 {

	public static void main(String[] args) {
		
		Random random = new Random(); 
		int number = random.nextInt(100); 

		
		int guess = 0; 

		
		BufferedReader input = new BufferedReader( 
		new InputStreamReader(System.in)); 

		
		int counter = 0; 

		System.out.println("我心里有一个0到99之间的整数，你猜是什么？"); 

		do { 
		try { 
		
		guess = Integer.parseInt(input.readLine()); 
		} catch (NumberFormatException e) { 
		
		System.out.println("请输入一个0-99之间的整数！"); 
		continue; 
		} catch (IOException e) { 
		System.out.println("程序发生异常错误将被关闭！"); 
		e.printStackTrace(); 
		} 

		
		if (guess > number) 
		System.out.println("大了点，再猜！"); 
		if (guess < number) 
		System.out.println("小了点，再试试！"); 

		
		counter++; 
		} while (guess != number); 


		
		switch (counter) { 
		case 1: 
		System.out.println("你太有才了"); 
		break; 
		case 2: 
		case 3: 
		case 4: 
		case 5: 
		case 6: 
		case 7: 
		System.out.println("这么快就猜对了，你很smart啊！"); 
		break; 
		default: 
		System.out.println("猜了半天才猜出来，小同志，尚须努力啊！"); 
		break; 
		} 

		System.out.println("Game Over!"); 
		} 
 	}


